Expand description
usvg
(micro SVG) is an SVG parser that tries to solve most of SVG complexity.
SVG is notoriously hard to parse. usvg
presents a layer between an XML library and
a potential SVG rendering library. It will parse an input SVG into a strongly-typed tree structure
were all the elements, attributes, references and other SVG features are already resolved
and presented in a simplest way possible.
So a caller doesn’t have to worry about most of the issues related to SVG parsing
and can focus just on the rendering part.
Features
- All supported attributes are resolved. No need to worry about inheritable, implicit and default attributes
- CSS will be applied
- Only simple paths
- Basic shapes (like
rect
andcircle
) will be converted into paths - Paths contain only absolute MoveTo, LineTo, CurveTo and ClosePath segments. ArcTo, implicit and relative segments will be converted
- Basic shapes (like
use
will be resolved and replaced with the reference content- Nested
svg
will be resolved - Invalid, malformed elements will be removed
- Relative length units (mm, em, etc.) will be converted into pixels/points
- External images will be loaded
- Internal, base64 images will be decoded
- Dummy groups will be removed
- All references (like
#elem
andurl(#elem)
) will be resolved switch
will be resolved- Text elements, which are probably the hardest part of SVG, will be completely resolved.
This includes all the attributes resolving, whitespaces preprocessing (
xml:space
), text chunks and spans resolving - Markers will be converted into regular elements. No need to place them manually
- All filters are supported. Including filter functions, like
filter="contrast(50%)"
- Recursive elements will be detected an removed
Limitations
- Unsupported SVG features will be ignored
- CSS support is minimal
- Only static SVG features,
e.g. no
a
,view
,cursor
,script
, no events and no animations
Re-exports
pub use roxmltree;
Modules
Structs
Representation of the
preserveAspectRatio
attribute.A generic gradient.
A text character position.
A clip-path element.
A 8-bit RGB color.
An
enable-background
.A fill style.
Text font properties.
A group container.
A raster image element.
An
xlink:href
resolver for <image>
elements.A linear gradient.
A mask element.
A non-zero
f64
.An immutable, finite
f64
that is known to be > 0.An immutable, finite
f64
in a 0..=1 range.Processing options.
A path element.
A path bbox representation.
An SVG path data container.
A path segments iterator.
A pattern element.
A 2D point representation.
An immutable, finite
f64
that is known to be >= 0.A radial gradient.
A rect representation.
A 2D screen rect representation.
A 2D screen size representation.
A 2D size representation.
Gradient’s stop element.
A stroke style.
A
stroke-miterlimit
value.A text element.
A text chunk.
A text span decoration.
A text span decoration style.
A path used by text-on-path.
A text style span.
Representation of the
<transform>
type.An iterator over transformed path segments.
A nodes tree container.
View box.
Enums
Representation of the
align
value of the preserveAspectRatio
attribute.An alignment baseline property.
A baseline shift property.
A blending mode property.
A dominant baseline property.
List of all errors.
A fill rule.
Image fit options.
An embedded image kind.
An image rendering method.
A length adjust property.
A line cap.
A line join.
Node’s kind.
A paint style.
Representation of the
paint-order
property.A path command.
A path’s absolute segment.
A shape rendering method.
A spread method.
A font stretch property.
A font style property.
A text chunk anchor property.
A text chunk flow property.
A text rendering method.
An element units.
A visibility property.
A writing mode.
Traits
A trait for approximate equality comparisons.
ApproxEqUlps is a trait for approximate equality comparisons.
The associated type Flt is a floating point type which implements Ulps, and is
required so that this trait can be implemented for compound types (e.g. vectors),
not just for the floats themselves.
A trait for fuzzy/approximate equality comparisons of float numbers.
A trait for fuzzy/approximate comparisons of float numbers.
Checks that type has a default value.
Checks that the current number is > 0.
Additional
Node
methods.Functions
Decompresses an SVGZ file.
Type Definitions
A shorthand for ImageHrefResolver’s data function.
A shorthand for ImageHrefResolver’s string function.
Alias for
rctree::Node<NodeKind>
.An alias to
NormalizedF64
.An alias to
NormalizedF64
.An alias to
NonZeroPositiveF64
.